package com.example.easy.Service.Impl;

import com.example.easy.Dto.Infobar;
import com.example.easy.Dto.Notice;
import com.example.easy.Dto.Visitor;
import com.example.easy.Service.myservice.InfobarServise;
import com.example.easy.Service.myservice.NoticeServise;
import com.example.easy.Service.myservice.VisitorServise;
import com.example.easy.mapper.InfobarMapper;
import com.example.easy.mapper.NoticeMapper;
import com.example.easy.mapper.VisitorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InfobarServiselmpl implements InfobarServise {

    @Autowired
    InfobarMapper infobarMapper;

   //插入
    @Override
    public int insInfobar(Infobar infobar) {
        return infobarMapper.insInfobar(infobar);
    }
   // 修改
    @Override
    public int updateInfobar(Infobar infobar) {
        if (infobarMapper.selectInfobar(infobar.getNumber()) != null) {
            infobarMapper.updateInfobar(infobar);
            return 1;
        } else return 0;
     }
    //删除
    @Override
    public int deleteInfobar(int number) {
        if (infobarMapper.selectInfobar(number) != null) {
            infobarMapper.deleteInfobar(number);
            return 1;
        } else return 0;
    }
//查找信息
    @Override
    public Infobar selectInfobar(int number) {
        if (infobarMapper.selectInfobar(number) != null) {
            return infobarMapper.selectInfobar(number);
        } else {
            return null;
        }
    }

    @Override
    public List<Infobar> selectall() {
        return infobarMapper.selectall();
    }
}
